package com.v5.mr.combiner.wc;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * 合并
 *
 */
public class WordCountMain {

	public static void main(String[] args) throws Exception {
		//创建一个job = mapper + reducer
		Job job = Job.getInstance(new Configuration());
		//指定job的入口
		job.setJarByClass(WordCountMain.class);
		
		//指定任务的mapper和输出数据类型
		job.setMapperClass(WordCountMapper.class);
		job.setMapOutputKeyClass(Text.class); //指定k2的类型
		job.setMapOutputValueClass(LongWritable.class);//指定v2的数据类型
		
		//设置任务的Combiner
		job.setCombinerClass(WordCountReducer.class);
		
		//指定任务的reducer和输出数据类型
		job.setReducerClass(WordCountReducer.class);
		job.setOutputKeyClass(Text.class);//指定k4的类型
		job.setOutputValueClass(LongWritable.class);//指定v4的类型
		
		//指定输入的路径和输出的路径
		FileInputFormat.setInputPaths(job, new Path(args[0]));
		FileOutputFormat.setOutputPath(job, new Path(args[1]));
		
		//执行任务
		job.waitForCompletion(true);
	}
}












